package com.gxa.luo.service.impl;



import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gxa.common.base.RespResult;
import com.gxa.luo.entity.FinancialPaymentDetails;
import com.gxa.luo.mapper.FinancialPaymentDetailsMapper;
import com.gxa.luo.service.FinancialPaymentDetailsService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
* @author 86180
* @description 针对表【financial_payment_details】的数据库操作Service实现
* @createDate 2023-04-10 16:55:13
*/
@Service
public class FinancialPaymentDetailsServiceImpl implements FinancialPaymentDetailsService{

    @Resource
    private FinancialPaymentDetailsMapper financialPaymentDetailsMapper;

    RespResult r = new RespResult();

    @Override
    public RespResult selCollectionByTime(String orderId,String starTime, String endTime) {
        List list = financialPaymentDetailsMapper.selCollectionByTime(orderId,starTime,endTime);

        if (list !=null){
            r.setCode(200);
            r.setMessage("查询成功");
            r.setData(list);
        }else {
            r.setCode(500);
            r.setMessage("查询失败");
        }
        return r;
    }

    @Override
    public RespResult selFinishCollectionByTime(String orderId,String starTime, String endTime) {
        List list = financialPaymentDetailsMapper.selFinishCollectionByTime(orderId,starTime,endTime);

        if (list !=null){
            r.setCode(200);
            r.setMessage("查询成功");
            r.setData(list);
        }else {
            r.setCode(500);
            r.setMessage("查询失败");
        }
        return r;
    }

    @Override
    public RespResult selUnfinCollectionByTime(String orderId,String starTime, String endTime) {
        List list = financialPaymentDetailsMapper.selUnfinCollectionByTime(orderId,starTime,endTime);

        if (list !=null){
            r.setCode(200);
            r.setMessage("查询成功");
            r.setData(list);
        }else {
            r.setCode(500);
            r.setMessage("查询失败");
        }
        return r;
    }

    @Override
    public RespResult allPayment() {

        Page<FinancialPaymentDetails> page = new Page<>();
        List list = financialPaymentDetailsMapper.allPayment(page);

        if (list !=null){
            r.setCode(200);
            r.setMessage("查询成功");
            r.setData(list);
        }else {
            r.setCode(500);
            r.setMessage("查询失败");
        }
        return r;
    }

    @Override
    public RespResult selMoneyByTime(String starTime, String endTime) {
        Page<FinancialPaymentDetails> page = new Page<>();
        List list = financialPaymentDetailsMapper.selMoneyByTime(starTime, endTime, page);
        System.out.println(list);

        Map map =new HashMap();
        map.put("totalmoney",list);
        map.put("details",financialPaymentDetailsMapper.selPaymentByTime(starTime, endTime, page));
        if (list !=null){
          return RespResult.success(map);
        }
        return RespResult.error("查询失败");
    }

    @Override
    public RespResult selFinMoneyByTime(String starTime, String endTime) {
        List list = financialPaymentDetailsMapper.selFinMoneyByTime(starTime, endTime);

        Map map =new HashMap();
        map.put("totalmoney",list);
        map.put("details",financialPaymentDetailsMapper.selFinPaymentByTime(starTime, endTime));
        if (list !=null){
            return RespResult.success(map);
        }
        return RespResult.error("查询失败");
    }

    @Override
    public RespResult selUnfinMoneyByTime(String starTime, String endTime) {
        List list = financialPaymentDetailsMapper.selUnfinMoneyByTime(starTime, endTime);
        System.out.println(list);

        Map map =new HashMap();
        map.put("totalmoney",list);
        map.put("details",financialPaymentDetailsMapper.selUnfinPaymentByTime(starTime, endTime));
        if (list !=null){
            return RespResult.success(map);
        }
        return RespResult.error("查询失败");
    }


    @Override
    public RespResult paymentPlan(String orderId, String starTime, String endTime) {
        List list = financialPaymentDetailsMapper.paymentPlan(orderId,starTime,endTime);

        if (list !=null){
            r.setCode(200);
            r.setMessage("查询成功");
            r.setData(list);
        }else {
            r.setCode(500);
            r.setMessage("查询失败");
        }
        return r;
    }

}







